#coding=utf-8 
import sys  
reload(sys)  
sys.setdefaultencoding('utf-8') 
import os
from selenium import webdriver
import logging
import ConfigParser

CHROME_DRIVER_PATH = sys.path[0]+os.sep+"driver"+os.sep+"chromedriver.exe"
IE_DRIVER_PATH = sys.path[0]+os.sep+"driver"+os.sep+"IEDriverServer.exe"

def initIeDriver():
	os.environ["webdriver.ie.driver"] = IE_DRIVER_PATH
	logging.info("ie driver path = "+IE_DRIVER_PATH)
	return webdriver.Ie(IE_DRIVER_PATH)

def initChromeDriver():
	os.environ["webdriver.chrome.driver"] = CHROME_DRIVER_PATH
	logging.info("chrome driver path = "+CHROME_DRIVER_PATH)
	return webdriver.Chrome(CHROME_DRIVER_PATH)

def saveErrorImage(browser,path):
	if os.path.exists(os.path.abspath(os.path.join(path,os.path.pardir))):
		logging.info('save error image path ->'+os.path.abspath('.')+os.sep+path)
		browser.get_screenshot_as_file(path)
	else:
		os.makedirs(os.path.abspath(os.path.join(path,os.path.pardir)))
		logging.info('save error image path ->'+os.path.abspath('.')+os.sep+path)
		browser.get_screenshot_as_file(path)

def getConfigValue(section,key):
	cf = ConfigParser.ConfigParser()
	cf.read("config"+os.sep+"common.conf")
	return cf.get(section, key)

def main():
	print "start util main"

if __name__=="__main__":
    main()